package com.jrx.anytxn.transaction.mapper.ext;

import com.jrx.anytxn.transaction.entity.TlRefundLog;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

public interface ExtTlRefundLogMapper {
    /**
     * 批量 - 根据状态查询退款流水
     *
     * @param sumStatus
     * @param grayVersion
     * @return
     */
    List<TlRefundLog> selectBySumStatus(@Param(value = "sumStatus") String sumStatus,
                                        @Param(value = "grayVersion") String grayVersion);

    void batchUpdateLogForBatch(List<TlRefundLog> list);

    List<TlRefundLog> selectByCustomerIdAndTenantId(String customerId, String tenantId);

    List<TlRefundLog> selectByCustomerIdProductIdsAndTenantId(@Param("customerId") String customerId, @Param("tenantId") String tenantId, @Param("productIds") List<String> products);

    /**
     * 溢缴款成功笔数
     * @param tenantId
     * @param sumStatus
     * @param businessDate
     * @param thirdChannel
     * @return
     */
    int countBySumStatusAndBusinessDateAndThirdChannel(
            @Param("tenantId") String tenantId,
            @Param("sumStatus") String sumStatus,
            @Param("businessDate") Date businessDate,
            @Param("thirdChannel") String thirdChannel);

    /**
     * 溢缴款成功金额
     * @param tenantId
     * @param sumStatus
     * @param businessDate
     * @param thirdChannel
     * @return
     */
    BigDecimal sumBySumStatusAndBusinessDateAndThirdChannel(
            @Param("tenantId") String tenantId,
            @Param("sumStatus") String sumStatus,
            @Param("businessDate") Date businessDate,
            @Param("thirdChannel") String thirdChannel);

    /**
     * 根据payId查询溢缴款金额
     * @param tenantId
     * @param payId
     * @return
     */
    BigDecimal queryRefundAmt(@Param("tenantId") String tenantId, @Param("payId") String payId);

    /**
     * 根据日期获取溢缴款信息
     * @param tenantId
     * @param businessDate
     * @return
     */
    List<TlRefundLog> queryRefundByBusinessDate(@Param("tenantId") String tenantId, @Param("businessDate") Date businessDate);

    /**
     * 微信还款对账场景中，考虑到切日情况，查询指定日期及其后一天以最大可能范围查询记录
     * @param tenantId
     * @param businessDate
     * @param thirdChannel
     * @return
     */
    List<TlRefundLog> selectForBillComparing(@Param("tenantId") String tenantId, @Param("businessDate") Date businessDate, @Param("thirdChannel") String thirdChannel);

}
